<template>
    <Modal v-model="visible" :title="title" :mask-closable="false" width="80%" >
        <!--表格-->
        <Table border stripe :columns="columns" :data="data.records" :loading="loading"></Table>
        <!--分页-->
        <pagination :data="data" :get-data="getLogList"></pagination>

        <div slot="footer">
            <Button type="text" size="large" @click.native="cancel">关闭</Button>
        </div>
    </Modal>
</template>

<script>
    import api from '../../api/index';
    import pagination from '../components/pagination';
    export default {
        props: ['getData'],
        components: {pagination},
        data () {
            return {
                visible: false,
                loading: false,
                filters: {},
                title: '财务系统管理日志信息',
                logType: {1: '启动', 2: '欠费', 3: '停止'},
                columns: [
                    {
                        key: 'type',
                        title: '类型',
                        render: (h, params) => {
                            return this.logType[params.row.type];
                        }
                    },
                    {
                        key: 'name',
                        title: '项目名称'
                    },
                    {
                        key: 'code',
                        title: '编码'
                    },
                    {
                        key: 'company',
                        title: '公司名称'
                    },
                    {
                        key: 'telephone',
                        title: '手机号'
                    },
                    {
                        key: 'userName',
                        title: '姓名'
                    },
                    {
                        key: 'paytime',
                        title: '到期时间'
                    },
                    {
                        key: 'endtime',
                        title: '到期时间'
                    },

                    {
                        key: 'ip',
                        title: '地址'
                    }

                ],
                data: {},
                form: {}
            };
        },
        methods: {
            getLogList (current, size, id) {
                this.form = {};
                this.visible = true;
                if (current) this.filters.current = current;
                if (size) this.filters.size = size;
                if (id) this.filters.statementsId = id;

                api.logIndex(this.filters).then(data => {
                    this.loading = false;
                    if (data.code === 0) {
                        this.data = data.data;
                    }
                });
            },
            cancel () {
                this.visible = false;
            }
        }
    };
</script>
